/*
 * Copyright 2016 Wealth Inc. All rights reserved.
 */
 package com.wealth.commodity.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import com.wealth.commodity.entity.Category;

import iaas.repository.BaseRepository;

/**
 * @author chan
 * @version 1.0
 * @since 1.0
 */
 
@Repository
public interface CategoryDao extends BaseRepository<Category, Long> ,JpaSpecificationExecutor<Category>{

	/** 查询商品分类 企业+状态 */
	public 	List<Category> findByStatusAndCorpId(Integer status,Long corpId);
	
	/** 查询商品分类 企业+市场+状态 */
	public 	List<Category> findByCorpIdAndMarketIdAndStatusOrderBySeqDesc(Long corpId,Long marketId,Integer status);
	
	/** 查询商品分类 企业+市场+状态+父节点 */
	public 	List<Category> findByCorpIdAndMarketIdAndStatusAndPcategoryIdIsNull(Long corpId,Long marketId,Integer status);

	/** 查询商品分类 企业+市场+状态+父节点 */
	public Category findByCorpIdAndMarketIdAndStatusAndPcategoryIdAndName(Long cropId,Long marketId, Integer status, Long pcategoryId,String name);
	
	public List<Category> findByPcategoryIdAndStatus(Long pcategoryId, Integer status);

	public List<Category> findByMarketIdAndStatusAndPcategoryIsNull(Long mid,Integer status);

	public Category findCategoryByCorpIdAndMarketIdAndPcategoryIsNullAndStatusAndName(
			Long corpId, Long marketId, Integer status,String name);

	public List<Category> findByStatusAndCorpIdAndMarketIdAndPcategoryIsNull(Integer value,Long corpid, Long marketId);

	public Category findByMarketIdAndPcategoryIdAndNameAndStatus(Long marketId, Long pcategoryId,String mName,Integer status);
	
	
	/**
	 * 查询商品分类的父分类(PC)
	 * @param corpId
	 * @param marketId
	 * @param status
	 * @return
	 */
	public 	List<Category> findByCorpIdAndStatusAndPcategoryIdIsNull(Long corpId,Integer status);
	public 	List<Category> findByCorpIdAndStatusAndPcategoryIdIsNotNull(Long corpId,Integer status);

	
}
